package com.lizhen.core.basicdatatype;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexDataType {
    public static void main(String[] args) {
        boolean b1 = Pattern.matches("\\d*", "123");
        Pattern r2 = Pattern.compile("(\\d+)(\\D+)");
        Matcher m2 = r2.matcher("123hhh");
        if (m2.find()) {
            m2.group(0);
            m2.group(1);
            m2.group(2);
            m2.start();
            m2.end();
            m2.lookingAt();
            m2.matches();
        }
        Pattern r3 = Pattern.compile("(\\d+)(\\D+)");
        Matcher m3 = r3.matcher("123hhh");
        StringBuffer sb3 = new StringBuffer();
        while (m3.find()) {
            m3.appendReplacement(sb3, "-");
        }
        m3.appendTail(sb3);
    }
}
